package jihe;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Test12 {
    public static void main(String[] args)
    {
        Scanner input=new Scanner(System.in);
        List srcList=new ArrayList();
        List destList=new ArrayList();
        destList.add("苏打水");
        destList.add("木糖醇");
        destList.add("方便面");
        destList.add("火腿肠");
        destList.add("冰红茶");
        System.out.println("原有商品如下：");
        for(int i=0;i<destList.size();i++)
        {
            System.out.println(destList.get(i));
        }
        System.out.println("输入替换的商品名称：");
        for(int i=0;i<3;i++)
        {
            System.out.println("第 "+(i+1)+" 个商品：");
            String name=input.next();
            srcList.add(name);
        }
        //调用copy()方法将当前商品信息复制到原有商品信息集合中
        Collections.copy(destList,srcList);
        System.out.println("当前商品有：");
        for(int i=0;i<destList.size();i++)
        {
            System.out.print(destList.get(i)+"\t");
        }
    }
}
